package com.ss.android.article.base.ui;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.TextView;

final class u implements TextWatcher {
    private final InputUserInfoDialog c;
    private int a;
    private int b;

    u(InputUserInfoDialog arg1) {
        this.c = arg1;

    }

    public final void afterTextChanged(Editable arg13) {
        int v11 = 30;
        int v10 = 10;
        long v6 = 0;
        this.a = this.c.e.getSelectionStart();
        this.b = this.c.e.getSelectionEnd();
        this.c.e.removeTextChangedListener(this.c.j);
        long v4 = InputUserInfoDialog.a((CharSequence) arg13.toString());
        TextView v3 = this.c.f;
        boolean v0 = v4 >= (((long) this.c.b)) ? true : false;
        v3.setEnabled(v0);
        if (this.c.c == 0) {
            if (this.c.a > v10 && v4 <= 10) {
                this.c.a = v10;
            }

            v4 = 10 - v4;
            v3 = this.c.g;
            String v8 = this.c.d;
            Object[] v9 = new Object[1];
            long v0_1 = v4 >= v6 ? v4 : v6;
            v9[0] = Long.valueOf(v0_1);
            v3.setText(String.format(v8, v9));
        } else {
            if (this.c.c != 1) {
//                goto label_51;
            } else {
                if (this.c.a > v11 && v4 <= 30) {
                    this.c.a = v11;
                }

                v4 = 30 - v4;
                TextView v0_2 = this.c.g;
                String v3_1 = this.c.d;
                Object[] v1 = new Object[1];
                if (v4 >= v6) {
                    v6 = v4;
                }

                v1[0] = Long.valueOf(v6);
                v0_2.setText(String.format(v3_1, v1));
            }
        }

        label_51:
        if (InputUserInfoDialog.a((CharSequence) arg13.toString()) > (((long) this.c.a))) {
            while (InputUserInfoDialog.a((CharSequence) arg13.toString()) > (((long) this.c.a))) {
                arg13.delete(this.a - 1, this.b);
                --this.a;
                --this.b;
            }

            this.c.e.setText(((CharSequence) arg13));
        }

        this.c.e.setSelection(this.a);
        this.c.e.addTextChangedListener(this.c.j);
    }

    public final void beforeTextChanged(CharSequence arg1, int arg2, int arg3, int arg4) {
    }

    public final void onTextChanged(CharSequence arg1, int arg2, int arg3, int arg4) {
    }
}

